package com.itheima.cases_demo.string_builder;

import java.util.ArrayList;
import java.util.StringJoiner;

public class Test2 {
    public static void main(String[] args) {
        // 测试 StringJoiner
        ArrayList<Integer> list = new ArrayList<>();
        list.add(100);
        list.add(200);
        list.add(300);
        list.add(400);
        list.add(500);
        list.add(600);
        list.add(700);
        list.add(800);
        StringJoiner stringJoiner = new StringJoiner(",", "[","]");
        for (int i = 0; i < list.size(); i++) {
            stringJoiner.add(list.get(i) + "");
        }
        String str = stringJoiner.toString();
        System.out.println(str);

    }
}
